package com.kylin.controller;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.kylin.service.StatService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 统计
 */
@RestController
@RequestMapping("/stat")
public class StatController {

    @Autowired
    private StatService statService;

    /**
     * 已完成题目数
     */
    @GetMapping("/getCompletedQuestions/{userName}")
    public String getCompletedQuestionsByUserName(@PathVariable("userName") String userName) {
        try {
            return statService.getCompletedQuestionsByUserName(userName);
        } catch (JsonProcessingException e) {
            e.printStackTrace();
            return null;
        }
    }
}
